package Java8.optional;

import java.util.Optional;

public class OptionalDemoTwo {

    public static void main(String[] args) {
        Optional<PrimeMinister> primeMinister = Optional.of(new PrimeMinister());
        Optional<Country> country = Optional.of(new Country(primeMinister));
        Optional<Person> person = Optional.of(new Person(country));
        String pmName = person.flatMap(Person::getCountry).flatMap(Country::getPrimeMinister).map(PrimeMinister::getName).orElse("None");
        System.out.println(pmName);


    }
}